#include "mainadmission.h"
#include "ui_mainadmission.h"

#include "source/connect.h"

MainAdmission::MainAdmission(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainAdmission)
{
    ui->setupUi(this);

    //qryProspectiveStudent = new QSqlTableModel(this);
    //qryProspectiveStudent->setTable("\"JPROSPECTIVE_STUDENT\"");
    //qryProspectiveStudent->select();

    qryProspectiveStudent->exec("SELECT \"TREEGROUP_ID\", \"TREEGROUP_PID\", \"treename\" FROM \"V_TREEGROUP\" WHERE \"TREEGROUP_PID\" = "+QString::number(pid);

    ui->tableProspectiveStudent->setModel(tblProspectiveStudent);

    connect(this, SIGNAL(UpdateDB()),this, SLOT(UpdateAll()));
}

MainAdmission::~MainAdmission()
{
    delete ui;
}

void MainAdmission::on_actionConnect_triggered()
{
    Connect *uc = new Connect(this);

    connect(uc, SIGNAL(Connected()), this, SIGNAL(UpdateDB()));

    uc->exec();
}

void MainAdmission::UpdateAll()
{
    tblProspectiveStudent->select();
}
